<%--
  Created by IntelliJ IDEA.
  User: 29858
  Date: 2023/11/7
  Time: 23:59
  To change this template use File | Settings | File Templates.
--%>
<%@ include file="../common/top.jsp"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div id="Catalog">
    <script type="text/javascript">
        //得到图片元素
        function changeCode(){
            var img = document.getElementsByTagName("img")[13];
            img.src = "vCode?time="+new Date().getTime();
        }
    </script>

    <script>


        $(function () {
            $('#username').on('blur',function () {
                $.ajax({
                    type	:"GET",
                    url		:"usernameIsExist?username="+this.value,
                    success	:function (data) {
                        if(data === 'Not Exist'){
                            $('#isExistInfo').attr("class",'okmsg').text('用户名可用');
                        }else if(data === 'NULL'){
                            $('#isExistInfo').attr("class",'errormsg').text('用户名不能为空');
                        }else{
                            $('#isExistInfo').attr("class",'errormsg').text('用户名不可用');
                        }
                    }
                });
            });
        });
    </script>




    <form action="newAccount" method="post">
        <fieldset>
            <legend>User Information</legend>

            <table>
                <tr>
                    <td><label for="username">User Name:</label></td>
                    <td>
                        <input type="text" name="username" id="username" >
                        <span id="isExistInfo" ></span>
                    </td>
                </tr>

                <tr>
                    <td><label for="password">password:</label></td>
                    <td><input type="password" name="password" id="password"></td>
                </tr>

                <tr>
                    <td><label for="repeatedPassword">Repeat password:</label></td>
                    <td><input type="password" name="repeatedPassword" id="repeatedPassword"/></td>

                </tr>

                <tr>
                    <td><label for="vCode">验证码:</label></td>
                    <td><input type="text" name="vCode" id="vCode"/></td>
                </tr>

                <tr>
                    <td>
                        <img id="loginCode" src="vCode">
                    </td>
                    <td>
                        <a href="javascript:changeCode()">看不清？换一张</a>
                    </td>
                </tr>
            </table>

            <%@ include file="IncludeAccountFields.jsp" %>
            <input type="submit" value="Save Account Information">
        </fieldset>
    </form>
</div>

<%@ include file="../common/bottom.jsp"%>